<?php
/**
* TopSites - Компонент каталога ссылок для Joostina CMS.
* @author:      Лаборатория сайтов, http://sitelab.net.ru
* @version:     1.9
* @release:     2010.02.07
* @package:     com_topsites
* @copyright:   (C) 2010 http://sitelab.net.ru,  see /administrator/components/com_topsites/copyright.php
* @license:     http://www.gnu.org/copyleft/gpl.html GNU/GPL
**/

defined( '_VALID_MOS' ) or die( '' );


function com_install() {

           $database = &database::getInstance();
		   global $mosConfig_absolute_path;
	 if (!defined('topsites_BASE'))  { DEFINE( 'topsites_BASE', 	$mosConfig_absolute_path.'/components/com_topsites'); }
	 if (!defined('topsites_ADMIN')) { DEFINE( 'topsites_ADMIN', $mosConfig_absolute_path.'/administrator/components/com_topsites'); }
	 if (!defined('THEME_OFFICE'))   { DEFINE( 'THEME_OFFICE', $mosConfig_absolute_path.'/includes/js/ThemeOffice/'); }


         $database->setQuery( "SELECT id FROM #__components WHERE name='topsites'" );
         $id = $database->loadResult();


         $file = THEME_OFFICE.'tl_logo.png';
	 if (!is_file($file)){
           if (!copy( topsites_ADMIN.'/images/tl_logo.png', $file))
		echo "не удалось скопировать $file...\n";
         }         
	 $database->setQuery( "UPDATE #__components SET admin_menu_img='js/ThemeOffice/tl_logo.png' WHERE id='$id'");
         $result[0] = $database->query();
         
	
         $file = THEME_OFFICE.'tl_edit.png';
	 if (!is_file($file)){
           if (!copy( topsites_ADMIN.'/images/tl_edit.png', $file))
		echo "не удалось скопировать $file...\n";;
	 }
         $database->setQuery( "UPDATE #__components SET admin_menu_img='js/ThemeOffice/tl_edit.png' WHERE parent='$id' AND name='Ссылки'");
         $result[1] = $database->query();

         
         $file = THEME_OFFICE.'tl_categories.png';
	 if (!is_file($file)){
           if (!copy( topsites_ADMIN.'/images/tl_categories.png', $file))
		echo "не удалось скопировать $file...\n";
	 }
         $database->setQuery( "UPDATE #__components SET admin_menu_img='js/ThemeOffice/tl_categories.png' WHERE parent='$id' AND name='Категории'");
         $result[2] = $database->query();  

		 
	 $file = THEME_OFFICE.'tl_settings.png';
	 if(!is_file($file)){
           if (!copy( topsites_ADMIN.'/images/tl_settings.png', $file))
		echo "не удалось скопировать $file...\n";
	 }
         $database->setQuery( "UPDATE #__components SET admin_menu_img='js/ThemeOffice/tl_settings.png' WHERE parent='$id' AND name='Настройки'");
         $result[3] = $database->query();
	 $database->setQuery("ALTER TABLE #__topsites ADD COLUMN `contact` text default ''");  
 	 $result[4] = $database->query();
		 $database->setQuery("ALTER TABLE #__topsites ADD COLUMN  `date_check` datetime NOT NULL default '0000-00-00 00:00:00'");  
 	 $result[5] = $database->query();
			 $database->setQuery("ALTER TABLE #__topsites ADD COLUMN `check_back` tinyint(1) unsigned NOT NULL default '0'");  
 	 $result[6] = $database->query();
	 }

?>
